﻿using Microsoft.Xaml.Behaviors;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MyWpfFramework.Pages
{
    /// <summary>
    /// uc_page.xaml 的交互逻辑
    /// </summary>
    public partial class uc_page : UserControl
    {
        public uc_page()
        {
            InitializeComponent();
            lsb.ItemsSource = new List<string>() { "1", "2" };
        }

        private void btnClick(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            TextBox bt = btn.Template.FindName("textBox", btn) as TextBox;
            MessageBox.Show(bt?.Text);
            
        }
    }
    public class MyBehavior : Behavior<Border>
    {
        protected override void OnAttached()
        {
            AssociatedObject.MouseEnter += (_, _) => AssociatedObject.Background = Brushes.AliceBlue;
            AssociatedObject.MouseLeave += (_, _) => AssociatedObject.Background = Brushes.Red;
        }
        protected override void OnDetaching()
        {
            
        }
    }
        
   
}
